package de.preamp.clients.java.utils;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * @author André Stannek
 * @since 2010-05-20
 * @version 2011-06-05
 */
public final class ImageLoader
{
    /**
     * Delegates to {@link Class#getResource(String)} to load an image with a
     * specified name, that is available in this package.
     * 
     * @param imagename
     *            the name of the image
     * @return the URL to the image or null if image does not exist
     */
    public static URL getImageURL(final String imagename)
    {
	try
	{
	    final File file = new File("src/main/resources/icons/" + imagename);
	    return file.toURI().toURL();
	}
	catch (final MalformedURLException e)
	{
	    return null;
	}
	// return ImageLoader.class.getResource(imagename);
    }

    /**
     * Masking default constructor of service class.
     */
    private ImageLoader()
    {
    }
}
